"""update models, delete task

Revision ID: d6c47750e1f7
Revises: fe2ea4b329bb
Create Date: 2025-09-17 17:30:29.953852

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'd6c47750e1f7'
down_revision: Union[str, None] = 'fe2ea4b329bb'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_tasks_file_id'), table_name='tasks')
    op.drop_index(op.f('ix_tasks_user_id'), table_name='tasks')
    op.drop_table('tasks')
    op.add_column('files', sa.Column('start_at', sa.DateTime(timezone=True), nullable=True))
    op.add_column('files', sa.Column('finish_at', sa.DateTime(timezone=True), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('files', 'finish_at')
    op.drop_column('files', 'start_at')
    op.create_table('tasks',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('user_id', sa.VARCHAR(length=64), nullable=False),
    sa.Column('file_id', sa.INTEGER(), nullable=False),
    sa.Column('type', sa.VARCHAR(length=32), nullable=True),
    sa.Column('status', sa.VARCHAR(length=32), nullable=True),
    sa.Column('progress', sa.FLOAT(), nullable=True),
    sa.Column('result', sa.TEXT(), nullable=True),
    sa.Column('created_at', sa.DATETIME(), nullable=True),
    sa.Column('updated_at', sa.DATETIME(), nullable=True),
    sa.ForeignKeyConstraint(['file_id'], ['files.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_tasks_user_id'), 'tasks', ['user_id'], unique=False)
    op.create_index(op.f('ix_tasks_file_id'), 'tasks', ['file_id'], unique=False)
    # ### end Alembic commands ###
